<layout name="driver" />

<style type="text/css">
	.vote {
	    margin-top: 9em;
	    padding: 1em;
	  }
	  .vote-title {
	    text-align: center;
	    margin-bottom: 1em;
	  }
	 .box {
			width: 75%;
			margin: 0 auto;
			padding: 2em 0 2em 0;
	 } 
	 .box .box-tit {
		  color: #C14268;
	 	  font-size: 1.8em;
	    font-weight: bold;
	 }
	 .box p {
		  color: #798998;
	   	font-size: 3em;
	 }
</style>
<div class="box">
	<p class="box-tit">荣威</p>
	<p>加油好的士</p>
</div>
<header class="driver-vote-header">
	<img class="w100" src="__STYLE__/Site/images/driver/driver-cart2.png" alt="加油好的士">
</header>
<div class="driver-vote tc">
	<h3 class="driver-vote-title mb1">输入服务号码为司机投票</h3>
	<form id="form" class="form" action="__CONTROLLER__/vote" method="post">
		<div class="form-item">
			<input class="form-control" type="text" name="service_no" placeholder="服务号码" required>
		</div>
		<button id="bt-submit" class="btn btn-blue driver-btn w100" type="submit">投票<small>领快的打车红包</small></button>
	</form>
</div>
<script type="text/javascript">
	(function(){
	    // 加载modal.js
	    GH.load( "js", "js-modal", "__COMMON__/js/modal.js" );
		var jumpUrl = "http://c2.kuaidadi.com/taxi/web/p/random_index.htm?activityUid=296adc61814e667326866cb80da771a2";
	    var form = GH.$( "#form" );
	    form.addEventListener( "submit", checkPost, false );
	
	    function checkPost (e) {
	      e.preventDefault();
	      if ( !GH.$( "#form input" ).value.trim() ) {
	        GH.showMessage( "还没有输入服务号码" );
	        return false;
	      };
	      postVote.call(this);
	    };
	
	    function postVote() {
	      var fd = GH.serialize( form );
	      var btSubmit = document.getElementById('bt-submit');
	      GH.showMessage('正在投票，请稍候……');
	      btSubmit.disabled='disabled';
	      setTimeout(function(){
	      	btSubmit.disabled='';
	      }, 10000);
	      fd.sid = {$sid};
	      fd._t = "{$_GET['_t']}";
	      fd._s = "{$_GET['_s']}";
	      fd.open_id = "{$_GET['open_id']}";
	      fd.term_id = "{$termId}";
	      GH.ajax(this.action, fd, function( data ){
	    	  if(data.error==0){
		        modal.alert({
		          title: "投票结果",
		          text: data.msg,
		          buttons:[
		          { "text": "确定", "close": true, "click": function(){} },
//		          { "text": "领取快的打车红包", "close": true, "click": function(){window.location.href = jumpUrl} }
		          ]
		        });
	    	  } else {
	    		  modal.alert({
			          title: "投票结果",
			          text: data.msg,
			          buttons:[
			          { "text": "确定", "close": true, "click": function(){} }
			          ]
			        });
	    	  }
	      });
	    };
	  })();
</script>